﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="/js/index.min.css"/>
    <script src="/js/jquery.min.js"></script>
    <script src="/js/vue.min.js"></script>
    <script src="/js/index.min.js"></script>
    <script src="/js/jquery.cookie.min.js"></script>
</head>
<body style="background-image: url('/img/bg.jpg');">
<div id="app">
    <el-row>
        <el-col :span="8" offset="8">
            <el-form>
                <el-form-item label="账号">
                    <el-input v-model="account"></el-input>
                </el-form-item>
                <el-form-item label="密码">
                    <el-input v-model="password"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button @click="login()">登录</el-button>
                </el-form-item>
            </el-form>
        </el-col>
    </el-row>
</div>
<script>
    var app = new Vue({
        el: "#app",
        data: {
            account: "a1",
            password: "123"
        },
        methods: {
            login () {
                $.post("/user/login", {
                    account: this.account,
                    password: this.password
                }, function (d) {
                    if (!d) {
                        location.href = "/login.html";
                        return;
                    }
                    $.cookie("account", d, {path: "/"});
                    location.href = "/con/index";
                });
            }
        }
    });
</script>
</body>
</html>
